<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript" th:src="@{/js/jquery-3.4.1.min.js}"></script>
</head>
<body>
	<table>
		<thead>
			<tr>
				<th>序号</th>
				<th>id</th>
				<th>名字</th>
				<th>标题</th>
				<th>cteateTime</th>
				<th>updateTime</th>
				<th>操作</th>
			</tr>
		</thead>

		<tbody>
			<tr th:each="hello : ${pageInfo.list}">
				<!-- 变量+Stat  index+1 -->
				<td th:text="${helloStat.index+1}"></td>
				<td th:text="${hello.id}"></td>
				<td th:text="${hello.name}"></td>
				<td th:text="${hello.title}"></td>
				<td th:text="${hello.cteateTime}"></td>
				<td th:text="${hello.updateTime}"></td>
				<!-- 删除有两种 一种直接删除 一种用input -->
				<td>
					<a th:href="@{/del(id=${hello.id})}"> delete </a>
					<input th:onclick="del([[${hello.id}]]);" value="修改" type="button">
				</td>
			</tr>
		</tbody>
	</table>
	<p>
		当前为
		<span th:text="${pageInfo.pageNum}"></span>
		页,总
		<span th:text="${pageInfo.pages}"></span>
		页,共
		<span th:text="${pageInfo.total}"></span>
		条记录
	</p>
	<a th:href="@{/getAllPerson}">首页</a>
	<a th:href="@{/getAllPerson(pageNum=${pageInfo.hasPreviousPage}?${pageInfo.prePage}:1)}">上一页</a>
	<a
		th:href="@{/getAllPerson(pageNum=${pageInfo.hasNextPage}?${pageInfo.nextPage}:${pageInfo.pages})}">下一页</a>
	<a th:href="@{/getAllPerson(pageNum=${pageInfo.pages})}">尾页</a>
</body>

<script type="text/javascript">
function del(id){
	if(id!=""){
		$.ajax({
            type: 'post',
            dataType: 'text',
            url:  '/del',
            data: {"id":id},
            cache: false,
            async: true,
            success: function (data) {
               alert("删除成功");
               location.reload();
            },err(data){
            	 alert("出错啦");
            }
        });
    
	}
}
</script>
</html>